import 'package:flutter/material.dart';

import 'package:get/get.dart';
import 'package:getwidget/components/dropdown/gf_dropdown.dart';

import '../controllers/gfdropdown_controller.dart';

class GfdropdownView extends GetView<GfdropdownController> {
  late String dropdown;

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text('下拉框'),
        centerTitle: true,
      ),
      body: Container(
        margin: EdgeInsets.all(10),
        child: ListView(
          children: [
            Container(
              height: 50,
              width: MediaQuery.of(context).size.width,
              margin: EdgeInsets.all(20),
              child: DropdownButtonHideUnderline(
                child: Obx(() {
                  return GFDropdown(
                    padding: const EdgeInsets.all(15),
                    borderRadius: BorderRadius.circular(10),
                    border: const BorderSide(color: Colors.black12, width: 1),
                    dropdownButtonColor: Colors.grey[300],
                    value: controller.selectedOption.value,
                    onChanged: (newValue) {
                      print(newValue);
                      controller.selectedOption.value = newValue.toString();
                    },
                    items: [
                      '男',
                      '女',
                      '保密',
                    ].map((value) => DropdownMenuItem(
                      value: value,
                      child: Text(value),
                    )).toList(),
                  );
                })
              ),
            ),
          ],
        ),
      ),
    );
  }
}
